// pages/hoteldetail/hoteldetail.js
Page({
  data: {
    useres: [],
    isShowConfirm: false,
    duihuanma:''
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '授权登录'
    })
  },



  duihuan: function (res) {
    var that = this
    // that.uid = res.data

    console.log(this.data.duihuanma.value)
   var call = require("../../utils/request.js")

    var url = 'duihuan?uid=' + wx.getStorageSync("uid") +'&duihuanma='+ that.data.duihuanma.value;

    var rese = call.getData(url, that.resduihuan, that.fail)
   

  },


    getInputValue: function (res) {

    this.setData({
      duihuanma: res.detail
    })
  },



  resduihuan: function (res) {
      if(res == 112){
        wx.showToast({
          title:'兑换码错误',
          icon: "none",

        });
      }

      if(res == 223){
        wx.showToast({
          title:'兑换码已被使用',
          icon: "none",

        });
      }

      if(res == 334){
        wx.showToast({
          title:'您已兑换过同类兑换卡,请消费完后再兑换',
          icon: "none",

        });
      }

      
      if(res == 567){



        setTimeout(() => {
          wx.showToast({
            title: '兑换成功',
            icon: "none",
          });
          setTimeout(() => {
            wx.reLaunch({
              url: '../pageck/duihuanjilu'
            })
          }, 2000)
        }, 0);


        
      }


  },

  








  quxiao: function (e) {
    wx.switchTab({
      url: '../mine/mine'
    })
  },




  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})